/*
 * JInternalFrameToolTips.java
 *
 * Copyright 2011 Universidad Francisco de Paula Santander (UFPS).
 * Todos los Derechos Reservados.
 * Created on 7/09/2010, 09:03:20 PM
 */

package com.ufps.cuatro.vistas;

import javax.swing.JList;

import org.jdesktop.application.Action;

import com.ufps.cuatro.CuatroView;
import com.ufps.cuatro.util.MsgInfo;
import com.ufps.cuatro.util.Utileria;
import com.ufps.cuatro.util.render.MyListRendererJLabel;

/**
 *<i><b>JInternalFrameToolTips:</b></i>@DefinicionClase
 * @author Carlos A. Torres C. - Dolly E. Guerrero. <https://code.google.com/p/tesis4dor/>
 * @version 1.0 7/09/2010
 * @see javax.swing.JInternalFrame
 */
public class JInternalFrameToolTips extends javax.swing.JInternalFrame {
    private static final long serialVersionUID = -4289671803188598008L;

    /** Creates new form JInternalFrameToolTips */
    public JInternalFrameToolTips() {
        initComponents();
        this.setFrameIcon(Utileria.leerIconoApp(Utileria.MODO_16x16));       
        CuatroView.strLabel = "";
        JList objLista = new JList(Utileria.objMSG.toArray());
        this.jListMensajes.setModel(objLista.getModel());
        MyListRendererJLabel objRenderer = new MyListRendererJLabel(Utileria.ARBOL_COMPONENTES);
        this.jListMensajes.setCellRenderer(objRenderer);
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jLabel1 = new javax.swing.JLabel();
        jScrollPane1 = new javax.swing.JScrollPane();
        jListMensajes = new javax.swing.JList();
        jLabel2 = new javax.swing.JLabel();
        jLabelDescripcion = new javax.swing.JLabel();
        jButton1 = new javax.swing.JButton();
        jButton2 = new javax.swing.JButton();
        jButton3 = new javax.swing.JButton();
        jLabel3 = new javax.swing.JLabel();

        setClosable(true);
        setIconifiable(true);
        setResizable(true);
        org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance().getContext().getResourceMap(JInternalFrameToolTips.class);
        setTitle(resourceMap.getString("Form.title")); // NOI18N
        setFrameIcon(resourceMap.getIcon("Form.frameIcon")); // NOI18N
        setName("Form"); // NOI18N

        jLabel1.setText(resourceMap.getString("jLabel1.text")); // NOI18N
        jLabel1.setName("jLabel1"); // NOI18N

        jScrollPane1.setName("jScrollPane1"); // NOI18N

        jListMensajes.setModel(new javax.swing.AbstractListModel() {
            String[] strings = { "Item 1", "Item 2", "Item 3", "Item 4", "Item 5" };
            public int getSize() { return strings.length; }
            public Object getElementAt(int i) { return strings[i]; }
        });
        jListMensajes.setName("jListMensajes"); // NOI18N
        jListMensajes.addListSelectionListener(new javax.swing.event.ListSelectionListener() {
            public void valueChanged(javax.swing.event.ListSelectionEvent evt) {
                jListMensajesValueChanged(evt);
            }
        });
        jScrollPane1.setViewportView(jListMensajes);

        jLabel2.setText(resourceMap.getString("jLabel2.text")); // NOI18N
        jLabel2.setName("jLabel2"); // NOI18N

        jLabelDescripcion.setBackground(resourceMap.getColor("jLabelDescripcion.background")); // NOI18N
        jLabelDescripcion.setText(resourceMap.getString("jLabelDescripcion.text")); // NOI18N
        jLabelDescripcion.setAutoscrolls(true);
        jLabelDescripcion.setBorder(javax.swing.BorderFactory.createEtchedBorder());
        jLabelDescripcion.setName("jLabelDescripcion"); // NOI18N
        jLabelDescripcion.setOpaque(true);

        javax.swing.ActionMap actionMap = org.jdesktop.application.Application.getInstance().getContext().getActionMap(JInternalFrameToolTips.class, this);
        jButton1.setAction(actionMap.get("cerrarVentana")); // NOI18N
        jButton1.setName("jButton1"); // NOI18N

        jButton2.setAction(actionMap.get("backMsg")); // NOI18N
        jButton2.setName("jButton2"); // NOI18N

        jButton3.setAction(actionMap.get("nextMsg")); // NOI18N
        jButton3.setName("jButton3"); // NOI18N

        jLabel3.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel3.setIcon(resourceMap.getIcon("jLabel3.icon")); // NOI18N
        jLabel3.setText(resourceMap.getString("jLabel3.text")); // NOI18N
        jLabel3.setName("jLabel3"); // NOI18N

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel1, javax.swing.GroupLayout.DEFAULT_SIZE, 163, Short.MAX_VALUE)
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 163, Short.MAX_VALUE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jLabel2, javax.swing.GroupLayout.DEFAULT_SIZE, 380, Short.MAX_VALUE)
                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
                        .addComponent(jButton2)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 52, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jButton3)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jButton1, javax.swing.GroupLayout.DEFAULT_SIZE, 180, Short.MAX_VALUE))
                    .addComponent(jLabelDescripcion, javax.swing.GroupLayout.DEFAULT_SIZE, 380, Short.MAX_VALUE))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel1)
                    .addComponent(jLabel2))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jLabelDescripcion, javax.swing.GroupLayout.DEFAULT_SIZE, 343, Short.MAX_VALUE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(jLabel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(jButton1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(jButton2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(jButton3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 390, Short.MAX_VALUE))
                .addGap(16, 16, 16))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jListMensajesValueChanged(javax.swing.event.ListSelectionEvent evt) {//GEN-FIRST:event_jListMensajesValueChanged
        if(!this.jListMensajes.isSelectionEmpty()){
            MsgInfo objMSG = (MsgInfo) this.jListMensajes.getSelectedValue();
            String strFormato = java.util.ResourceBundle.getBundle("com/ufps/cuatro/vistas/resources/JInternalFrameToolTips").getString("<HTML><B>") + objMSG.getStrTitulo() + java.util.ResourceBundle.getBundle("com/ufps/cuatro/vistas/resources/JInternalFrameToolTips").getString("</B><BR>");
            strFormato += objMSG.getStrMSG() + java.util.ResourceBundle.getBundle("com/ufps/cuatro/vistas/resources/JInternalFrameToolTips").getString("</HTML>");
            this.jLabelDescripcion.setText(strFormato);
        }
    }//GEN-LAST:event_jListMensajesValueChanged

    /**
     * Permite cerrar la ventana seleccionada
     */
    @Action
    public void cerrarVentana() {
//        String strMsg = Utileria.leerRecursoTexto("Utileria.msg.salir.window");
//        String strTitle = Utileria.leerRecursoTexto("Utileria.app.name");
//        if(Utileria.confirmarOrden(this, strMsg, strTitle)){
            dispose();
//        }
    }

    /**
     * Permite cargarArchivoMyPropierties el mensaje anterior
     */
    @Action
    public void backMsg() {
    }

    /**
     * Permite cargarArchivoMyPropierties el mensaje siguiente
     */
    @Action
    public void nextMsg() {
    }


    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButton2;
    private javax.swing.JButton jButton3;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabelDescripcion;
    private javax.swing.JList jListMensajes;
    private javax.swing.JScrollPane jScrollPane1;
    // End of variables declaration//GEN-END:variables

}
